/**
 * This file is loaded via the <script> tag in the index.html file and will
 * be executed in the renderer process for that window. No Node.js APIs are
 * available in this process because `nodeIntegration` is turned off and
 * `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
 * to expose Node.js functionality from the main process.
 */

// const setButton = document.getElementById('btn')
// const titleInput = document.getElementById('title')
// setButton.addEventListener('click', () => {
//   const title = titleInput.value
//   window.electronAPI.setTitle(title)
// })



// 渲染进程 (renderer.js)
const { ipcRenderer } = require('electron');

// 触发文件选择对话框
// document.getElementById('uploadSample').addEventListener('click', () => {

//   ipcRenderer.send('open-file-dialog');
// });


window.addEventListener("message",function(e){
  // console.log(e);
  // type 上传文件夹
  // console.log(e.data.type == 1);
  if(e.data.type == 1){
    // console.log(2)
     ipcRenderer.send('open-folder-dialog');
  }
})
// 接收主进程发送的文件路径
// ipcRenderer.on('selected-file-path', (event, filePath) => {
//   console.log('选中的文件路径：', filePath);
// });

// 接收主进程发送的文件夹路径
ipcRenderer.on('selected-folder-path', (event, filePath) => {
  console.log('选中的文件路径：', filePath);
  document.getElementById("myIframe").contentWindow.postMessage({"callType":1,"path":filePath},"*")
});


